<!--
 * @description  : 移送变价案件扫码界面--测试
 * @descriptionDetail: 移送变价案件扫码界面--测试
 * @copyright    : 河北烟草
 * @author       : gys
 * @create       : 2024-06-19 08:30:00
-->

<template>
  <view class="page">
    <!-- #ifdef H5-ONLY -->
    <theme-navbar :is-white="false" :custom-back="goBack" style="z-index: 99999" :title="navTitle">
    </theme-navbar>
    <!-- #endif -->
    <view class="content">
      <u-button type="primary" @click="scanH5">扫码（H5）</u-button>
    </view>
  </view>
</template>

<script>
import commonService from '@/service/common/common.service.js';
import { aesDecrypt } from '@/common/crypto.util.js';

export default {
  data() {
    return {
      headImgSrc: require('../../../static/store/erweima.png')
    }
  },
  onLoad() {
  },
  created() {
    this.init();
  },
  methods: {
    init() {
    },

    // 扫码方法
    scanH5() {
      let that = this;
      // this.$deviceApi.scan().then((res) => {
      //   that.jiema(scanres);
      // });
      let scanres = '4wflxsAu2yA+HsP4x31Kt2riLmiKsZCoIItSLO7JOxGAfn3OrWAp20nd4q+0egw4+Z7F342jdU3urYqh+ybZ68qQOJehQWAQ+/1J5xozWKLOGNe5xj+FS/DO1OHBql38NjFKkP5Lg9ACR2YKCykUjg==';
      let scan = 'Kw2DbUG2ImbkGovdhIbvaUnBvxRKvfzQXBgBXUGUn+D+KjbJAlG0lEfAl0wSGuCFVSa8qTbG9OTt4rL4pFFanpuxKWauTfxEnshZxlmuQUwr2sniH+/V3XqJ4ig6p+xALeQ5ndWITUXD/hojOOJx7sFzi63tibt2Wr0OcC+HZkG1hsCpK/xllHldpDp5NNZ5ejMHIANq7El+fNzeuMWA7w==';
      that.jiema(scan);
    },

    // 解码方法
    jiema(data) {
      const str = data;
      commonService.getSysConfig("qr_code", "qr_code_key").then((res) => {
        if (res.code == 0 && res.success && res.msg) {
          let key = res.msg;
          let data = aesDecrypt(str, key);
          console.log('-----',data);
          let params = JSON.parse(data);
          params.isAddGoods = false;
          params.formTo = 'scan';
          this.setRouteParam(params);
          this.$u.route(params.url);
        } else {
          this.$u.toast(res.msg);
        }
      }).catch((err) => {
        this.$u.toast(err.msg || "获取解密秘钥失败");
      })
    },
  },
}
</script>

<style scoped lang="scss">
.page {
  padding: 28rpx 30rpx;
}

.content {
  padding-bottom: 10rpx;
}
</style>